/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tpiServeur;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;


/**
 * @date 13 avr. 2011
 * @time 13:53:47
 * @author Luis.HAFNER
 */
public class ModeleServeur {

    private ArrayList<String> noms = new ArrayList<String>();
    private String ipLocale;
    private ArrayList<String> texte;

    public ModeleServeur(){
        try {
            this.ipLocale = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException ex) {
            System.out.println(ex);
        }
    }

    public String getIPLocale() {
        return ipLocale;
    }

    public boolean inscrireClient(String nom){
        int i;
        for(i=0;i<this.noms.size();i++)
            if(noms.get(i).equals(nom))
                return false;
        this.noms.add(nom);
        return true;
    }

    // Desinscrit un client du chat
    public void desinscrireClient(String nom){
        int i;
        for(i=0;i<this.noms.size();i++)
            if(noms.get(i).equals(nom))
                this.noms.remove(i);
    }

    public String[] getNoms() {
        return (String[]) noms.toArray();
    }

}



